#include "stdafx.h"
#include "game/gamewrapper.h"
#include "./player.h"

Player::Player(int id,
			   string strName, 
			   Point startPos, 
			   float startAngle, 
			   Point hpPos,
			   float z,
			   Color color)
: m_id(id)
, m_bDestroyed(false)
, m_tankObj(id, strName, startPos, startAngle, color)
, m_hpObj(strName, hpPos, z, color)
{
	m_tankObj.OnImpacted += EventObject<OnTankImpactedFunc>(this, &Player::OnTankImpacted);
}

Player::~Player()
{
}

void Player::DoMsg(TankMsg* pMsg)
{
	if (pMsg)
	{
		m_tankObj.DoMsg(pMsg);
	}
}

void Player::Destroy()
{
	m_bDestroyed = true;
	m_tankObj.DestroyTank();
}

void Player::OnTankImpacted()
{
	m_hpObj.DecreaseLife();
	if (m_hpObj.GetLifePoint() == 0)
	{
		FireEvent(OnPlayerDestroyFunc, OnDestroy, ());
	}
}

int Player::GetID()
{
	return m_id;
}

bool Player::GetDestroyed()
{
	return m_bDestroyed;
}

Point Player::GetPos()
{
	return m_tankObj.GetPos();
}

bool Player::GetGo()
{
	return m_tankObj.GetGo();
}

float Player::GetRollAngle()
{
	return m_tankObj.GetRollAngle();
}

float Player::GetGunAngle()
{
	return m_tankObj.GetGunAngle();
}

float Player::GetSpeed()
{
	return m_tankObj.GetSpeed();
}

float Player::GetRollSpeed()
{
	return m_tankObj.GetRollSpeed();
}

float Player::GetGunSpeed()
{
	return m_tankObj.GetGunSpeed();
}